<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>ES入门 - 环境安装 | java知识体系</title>
    <meta name="generator" content="VuePress 1.9.7">
    <link rel="icon" href="/lm_blog_vdoing/img/favicon.ico">
    <meta name="description" content="lm_blog">
    <meta name="author" content="小猫爱吃鱼">
    <meta name="keywords" content="小猫爱吃鱼|java开发学习">
    <link rel="preload" href="/lm_blog_vdoing/assets/css/0.styles.6837ef6d.css" as="style"><link rel="preload" href="/lm_blog_vdoing/assets/js/app.fa0e5fdd.js" as="script"><link rel="preload" href="/lm_blog_vdoing/assets/js/2.d9c93b35.js" as="script"><link rel="preload" href="/lm_blog_vdoing/assets/js/25.04906008.js" as="script"><link rel="preload" href="/lm_blog_vdoing/assets/js/5.e0bc0396.js" as="script"><link rel="preload" href="/lm_blog_vdoing/assets/js/13.ee87d1ca.js" as="script"><link rel="preload" href="/lm_blog_vdoing/assets/js/14.9d4d9cf6.js" as="script"><link rel="preload" href="/lm_blog_vdoing/assets/js/9.fc3a629f.js" as="script"><link rel="preload" href="/lm_blog_vdoing/assets/js/10.4c34cde9.js" as="script"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/11.bccd7768.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/12.e841fec0.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/15.ea506303.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/16.2da770e9.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/17.2e0242dc.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/18.304c9e7d.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/19.4b93faf0.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/20.87daf9d0.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/21.058f688b.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/22.9937ce9d.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/23.87e8eccb.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/24.1688627c.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/26.494f706b.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/27.01c810da.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/28.9fbe8e29.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/29.3a1e938a.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/3.80bae7d2.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/30.4adb3ea1.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/31.5001aed0.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/32.306c6420.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/33.5fcce29f.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/34.2de40b8f.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/4.d2df651a.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/6.cbc45c4c.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/7.fd589d8e.js"><link rel="prefetch" href="/lm_blog_vdoing/assets/js/8.35156f8e.js">
    <link rel="stylesheet" href="/lm_blog_vdoing/assets/css/0.styles.6837ef6d.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/lm_blog_vdoing/" class="home-link router-link-active"><!----> <span class="site-name">java知识体系</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/lm_blog_vdoing/" class="nav-link">首页​</a></div><div class="nav-item"><a href="/lm_blog_vdoing/pages/f6054a/" class="nav-link">❁导航​</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="计算机核心" class="dropdown-title"><!----> <span class="title" style="display:;">计算机核心</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/db72cf/" class="nav-link">数据结构</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/39e2a1/" class="nav-link">计算机网络</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Java" class="dropdown-title"><!----> <span class="title" style="display:;">Java</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>Java基础</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/e05ef5/" class="nav-link">JavaSE</a></li></ul></li><li class="dropdown-item"><h4>JavaWeb</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/5cda88/" class="nav-link">HTML</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/cea341/" class="nav-link">CSS</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/d893c0/" class="nav-link">JavaScript</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/8f83ba/" class="nav-link">Servlet</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/8bc1c4/" class="nav-link">MVC</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/f883e2/" class="nav-link">filter|listener</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Spring生态" class="dropdown-title"><!----> <span class="title" style="display:;">Spring生态</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/462a90/" class="nav-link">Spring5</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/2e990c/" class="nav-link">SpringMVC</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/0d4af0/" class="nav-link">SpringBoot2</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/870083/" class="nav-link">SpringCloud</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/66babb/" class="nav-link">SpringSecurity</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="中间件" class="dropdown-title"><!----> <span class="title" style="display:;">中间件</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>消息队列</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/e645d9/" class="nav-link">RabbitMQ</a></li></ul></li><li class="dropdown-item"><h4>服务器</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/9551ee/" class="nav-link">Nginx🌐</a></li></ul></li><li class="dropdown-item"><h4>服务框架</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/48771f/" class="nav-link">Dubbo</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="大数据" class="dropdown-title"><!----> <span class="title" style="display:;">大数据</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>Python</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/b9268d/" class="nav-link">Python基础</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/e0bd06/" class="nav-link">数据分析</a></li></ul></li><li class="dropdown-item"><h4>环境搭建</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/600247/" class="nav-link">Hadoop集群</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/cdeb68/" class="nav-link">KVM虚拟化技术</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="数据库" class="dropdown-title"><!----> <span class="title" style="display:;">数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>SQL 数据库</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/e72480/" class="nav-link">MySQL</a></li></ul></li><li class="dropdown-item"><h4>NoSQL 数据库</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/e9cc9f/" class="nav-link">Redis</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/91197c/" class="nav-link">MongoDB</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/7b46ed/" class="nav-link">ElasticSearch</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="工具" class="dropdown-title"><!----> <span class="title" style="display:;">工具</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>部署</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/99e9dc/" class="nav-link">Linux</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/90cc29/" class="nav-link">Docker</a></li></ul></li><li class="dropdown-item"><h4>管理</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/45eca1/" class="nav-link">Maven</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/34892c/" class="nav-link">Git</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="面试" class="dropdown-title"><!----> <span class="title" style="display:;">面试</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/eab19d/" class="nav-link">十大排序算法</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/40ee62/" class="nav-link">力扣算法题</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/39558d/" class="nav-link">初级开发篇</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/47c622/" class="nav-link">中高进阶篇</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="更多" class="dropdown-title"><!----> <span class="title" style="display:;">更多</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/myfriends/" class="nav-link">友情链接</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="本站" class="dropdown-title"><!----> <span class="title" style="display:;">本站</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>索引</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/categories/" class="nav-link">分类</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/tags/" class="nav-link">标签</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/archives/" class="nav-link">归档</a></li></ul></li><li class="dropdown-item"><h4>其他</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/9013e4/" class="nav-link">关于</a></li></ul></li></ul></div></div> <a href="https://gitee.com/lmgghub/lm_blog" target="_blank" rel="noopener noreferrer" class="repo-link">
    查看源码
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><div class="blogger"><img src="https://cdn.staticaly.com/gh/xustudyxu/image-hosting@master/20220627/mmexport1656324824543.124zxwkqyzlc.webp"> <div class="blogger-info"><h3>lm_blog</h3> <span>持续学习!</span></div></div> <nav class="nav-links"><div class="nav-item"><a href="/lm_blog_vdoing/" class="nav-link">首页​</a></div><div class="nav-item"><a href="/lm_blog_vdoing/pages/f6054a/" class="nav-link">❁导航​</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="计算机核心" class="dropdown-title"><!----> <span class="title" style="display:;">计算机核心</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/db72cf/" class="nav-link">数据结构</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/39e2a1/" class="nav-link">计算机网络</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Java" class="dropdown-title"><!----> <span class="title" style="display:;">Java</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>Java基础</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/e05ef5/" class="nav-link">JavaSE</a></li></ul></li><li class="dropdown-item"><h4>JavaWeb</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/5cda88/" class="nav-link">HTML</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/cea341/" class="nav-link">CSS</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/d893c0/" class="nav-link">JavaScript</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/8f83ba/" class="nav-link">Servlet</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/8bc1c4/" class="nav-link">MVC</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/f883e2/" class="nav-link">filter|listener</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Spring生态" class="dropdown-title"><!----> <span class="title" style="display:;">Spring生态</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/462a90/" class="nav-link">Spring5</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/2e990c/" class="nav-link">SpringMVC</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/0d4af0/" class="nav-link">SpringBoot2</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/870083/" class="nav-link">SpringCloud</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/66babb/" class="nav-link">SpringSecurity</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="中间件" class="dropdown-title"><!----> <span class="title" style="display:;">中间件</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>消息队列</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/e645d9/" class="nav-link">RabbitMQ</a></li></ul></li><li class="dropdown-item"><h4>服务器</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/9551ee/" class="nav-link">Nginx🌐</a></li></ul></li><li class="dropdown-item"><h4>服务框架</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/48771f/" class="nav-link">Dubbo</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="大数据" class="dropdown-title"><!----> <span class="title" style="display:;">大数据</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>Python</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/b9268d/" class="nav-link">Python基础</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/e0bd06/" class="nav-link">数据分析</a></li></ul></li><li class="dropdown-item"><h4>环境搭建</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/600247/" class="nav-link">Hadoop集群</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/cdeb68/" class="nav-link">KVM虚拟化技术</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="数据库" class="dropdown-title"><!----> <span class="title" style="display:;">数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>SQL 数据库</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/e72480/" class="nav-link">MySQL</a></li></ul></li><li class="dropdown-item"><h4>NoSQL 数据库</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/e9cc9f/" class="nav-link">Redis</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/91197c/" class="nav-link">MongoDB</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/7b46ed/" class="nav-link">ElasticSearch</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="工具" class="dropdown-title"><!----> <span class="title" style="display:;">工具</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>部署</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/99e9dc/" class="nav-link">Linux</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/90cc29/" class="nav-link">Docker</a></li></ul></li><li class="dropdown-item"><h4>管理</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/45eca1/" class="nav-link">Maven</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/34892c/" class="nav-link">Git</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="面试" class="dropdown-title"><!----> <span class="title" style="display:;">面试</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/eab19d/" class="nav-link">十大排序算法</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/40ee62/" class="nav-link">力扣算法题</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/39558d/" class="nav-link">初级开发篇</a></li><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/47c622/" class="nav-link">中高进阶篇</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="更多" class="dropdown-title"><!----> <span class="title" style="display:;">更多</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/lm_blog_vdoing/pages/myfriends/" class="nav-link">友情链接</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="本站" class="dropdown-title"><!----> <span class="title" style="display:;">本站</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>索引</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/categories/" class="nav-link">分类</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/tags/" class="nav-link">标签</a></li><li class="dropdown-subitem"><a href="/lm_blog_vdoing/archives/" class="nav-link">归档</a></li></ul></li><li class="dropdown-item"><h4>其他</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/lm_blog_vdoing/pages/9013e4/" class="nav-link">关于</a></li></ul></li></ul></div></div> <a href="https://gitee.com/lmgghub/lm_blog" target="_blank" rel="noopener noreferrer" class="repo-link">
    查看源码
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>MySQL - 基础</span> <!----></p> <!----></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>MySQL - 进阶</span> <!----></p> <!----></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>MySQL - 运维部署</span> <!----></p> <!----></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>NoSQL - Redis</span> <!----></p> <!----></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>NoSQL - MongoDB</span> <!----></p> <!----></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>NoSQL - ElasticSearch</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/lm_blog_vdoing/pages/7b46ed/" class="sidebar-link">ElasticeSarch的概述</a></li><li><a href="/lm_blog_vdoing/pages/596552/" aria-current="page" class="active sidebar-link">ES入门 - 环境安装</a></li><li><a href="/lm_blog_vdoing/pages/bc6018/" class="sidebar-link">ES入门 - 基本使用：索引和文档</a></li><li><a href="/lm_blog_vdoing/pages/6e6e0c/" class="sidebar-link">ES入门 - 分片和副本</a></li><li><a href="/lm_blog_vdoing/pages/3d97b1/" class="sidebar-link">ES入门 - 分析器</a></li><li><a href="/lm_blog_vdoing/pages/b54e3a/" class="sidebar-link">ES入门 - java整合</a></li><li><a href="/lm_blog_vdoing/pages/7e4dff/" class="sidebar-link">ES进阶 - 分片操作原理</a></li><li><a href="/lm_blog_vdoing/pages/b82771/" class="sidebar-link">ES进阶 - 并发问题</a></li><li><a href="/lm_blog_vdoing/pages/c3becc/" class="sidebar-link">ES进阶 - 集群搭建</a></li><li><a href="/lm_blog_vdoing/pages/6d9622/" class="sidebar-link">ES进阶 - 优化配置</a></li><li><a href="/lm_blog_vdoing/pages/da009f/" class="sidebar-link">ES进阶 - 框架整合</a></li><li><a href="/lm_blog_vdoing/pages/7cb809/" class="sidebar-link">ElasticSearch面试题</a></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-1baff76c><div class="articleInfo" data-v-1baff76c><ul class="breadcrumbs" data-v-1baff76c><li data-v-1baff76c><a href="/lm_blog_vdoing/" title="首页" class="iconfont icon-home router-link-active" data-v-1baff76c></a></li> <li data-v-1baff76c><a href="/lm_blog_vdoing/categories/?category=notes" title="分类" data-v-1baff76c>notes</a></li><li data-v-1baff76c><a href="/lm_blog_vdoing/categories/?category=database" title="分类" data-v-1baff76c>database</a></li><li data-v-1baff76c><a href="/lm_blog_vdoing/categories/?category=elasticSearch" title="分类" data-v-1baff76c>elasticSearch</a></li></ul> <div class="info" data-v-1baff76c><div title="作者" class="author iconfont icon-touxiang" data-v-1baff76c><a href="javascript:;" data-v-1baff76c>lm</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-1baff76c><a href="javascript:;" data-v-1baff76c>2023-02-13</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">ES入门 - 环境安装<!----></h1> <!----> <div class="theme-vdoing-content content__default"><h1 id="es入门-环境安装"><a href="#es入门-环境安装" class="header-anchor">#</a> ES入门 - 环境安装</h1> <h2 id="windows上安装es"><a href="#windows上安装es" class="header-anchor">#</a> Windows上安装ES</h2> <h3 id="下载软件"><a href="#下载软件" class="header-anchor">#</a> 下载软件</h3> <p><a href="https://www.elastic.co/cn/" target="_blank" rel="noopener noreferrer">ElasticSearch官网<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://www.elastic.co/cn/downloads/past-releases#elasticsearch" target="_blank" rel="noopener noreferrer">ElasticSearch下载地址<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p>本文档使用的是 ElasticSearch7.8.0 版本</p> <p><img alt="es_002" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_002.jpg" loading="lazy" class="lazy"></p> <h3 id="安装软件"><a href="#安装软件" class="header-anchor">#</a> <strong>安装软件</strong></h3> <p>Windows 版的 ElasticSearch 的安装很简单，解压即安装完毕，解压后的 ElasticSearch 的目录结构如下</p> <p><img alt="es_003" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_003.jpg" loading="lazy" class="lazy"></p> <table><thead><tr><th style="text-align:left;">目录</th> <th style="text-align:left;">含义</th></tr></thead> <tbody><tr><td style="text-align:left;">bin</td> <td style="text-align:left;">可执行脚本目录</td></tr> <tr><td style="text-align:left;">config</td> <td style="text-align:left;">配置目录</td></tr> <tr><td style="text-align:left;">jdk</td> <td style="text-align:left;">内置JDK目录</td></tr> <tr><td style="text-align:left;">lib</td> <td style="text-align:left;">类库</td></tr> <tr><td style="text-align:left;">logs</td> <td style="text-align:left;">日志目录</td></tr> <tr><td style="text-align:left;">moudules</td> <td style="text-align:left;">模块目录</td></tr> <tr><td style="text-align:left;">plugins</td> <td style="text-align:left;">插件目录</td></tr></tbody></table> <p>解压后，进入 bin 文件目录，点击 elasticsearch.bat 文件启动 ES 服务</p> <blockquote><p>注意:<strong>9300</strong> 端口为 ElasticSearch 集群间组件的通信端口，<strong>9200</strong> 端口为浏览器访问的 http协议 RESTful 端口。</p></blockquote> <p>打开浏览器（推荐使用谷歌浏览器），输入地址：http://localhost:9200，测试结果</p> <p><img alt="es_004" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_004.webp" loading="lazy" class="lazy"></p> <h3 id="遇到问题"><a href="#遇到问题" class="header-anchor">#</a> 遇到问题</h3> <ul><li><p>ElasticSearch 是使用 java 开发的，且 7.8 版本的 ES 需要 JDK 版本 1.8 以上，默认安装包带有 jdk 环境，如果系统配置 JAVA_HOME，那么使用系统默认的 JDK，如果没有配置使用自带的 JDK，一般建议使用系统配置的 JDK。</p></li> <li><p>双击启动窗口闪退，通过路径访问追踪错误，如果是“空间不足”，请修改config/jvm.options 配置文件</p></li></ul> <div class="language-properties line-numbers-mode"><pre class="language-properties"><code><span class="token comment"># 设置 JVM 初始内存为 1G。此值可以设置与-Xmx 相同，以避免每次垃圾回收完成后 JVM 重新分配内存</span>
<span class="token comment"># Xms represents the initial size of total heap space</span>
<span class="token comment"># 设置 JVM 最大可用内存为 1G</span>
<span class="token comment"># Xmx represents the maximum size of total heap space</span>
-Xms1g
-Xmx1g
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h2 id="windows上安装kibana"><a href="#windows上安装kibana" class="header-anchor">#</a> Windows上安装Kibana</h2> <p>Kibana 是一个免费且开放的用户界面，能够让你对 ElasticSearch 数据进行可视化，并 让你在 Elastic Stack 中进行导航。你可以进行各种操作，从跟踪查询负载，到理解请求如 何流经你的整个应用，都能轻松完成。</p> <p>下载时尽量下载与 ElasicSearch 一致的版本。</p> <h3 id="下载软件-2"><a href="#下载软件-2" class="header-anchor">#</a> 下载软件</h3> <p><a href="https://www.elastic.co/cn/downloads/past-releases#kibana" target="_blank" rel="noopener noreferrer">Kibana下载地址<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><img alt="es_005" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_005.jpg" loading="lazy" class="lazy"></p> <p>下载后进行解压，目录如图：</p> <p><img alt="es_010" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_010.jpg" loading="lazy" class="lazy"></p> <blockquote><p>注意：启动 Kibana 之前要启动 ElasticSearch</p></blockquote> <h3 id="修改配置"><a href="#修改配置" class="header-anchor">#</a> 修改配置</h3> <p>进入根目录下的 config 目录，打开 <code>kibana.yml</code> 文件</p> <p>修改以下配置文件</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token comment"># 默认端口</span>
<span class="token key atrule">server.port</span><span class="token punctuation">:</span> <span class="token number">5601</span>
<span class="token comment"># ES 服务器的地址</span>
<span class="token key atrule">elasticsearch.hosts</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">&quot;http://localhost:9200&quot;</span><span class="token punctuation">]</span>
<span class="token comment"># 索引名</span>
<span class="token key atrule">kibana.index</span><span class="token punctuation">:</span> <span class="token string">&quot;.kibana&quot;</span>
<span class="token comment"># 支持中文</span>
<span class="token key atrule">i18n.locale</span><span class="token punctuation">:</span> <span class="token string">&quot;zh-CN&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>进入 bin 目录，双击 <code>kibana.bat</code> 启动服务</p> <p>打开浏览器（推荐使用谷歌浏览器），输入地址：http://localhost:5601/，测试结果</p> <p><img alt="es_011" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_011.jpg" loading="lazy" class="lazy"></p> <p>可以连接<strong>ElasticSearch</strong>索引，或者进入控制台进行操作</p> <p><img alt="es_013" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_013.jpg" loading="lazy" class="lazy"></p> <p><img alt="es_012" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_012.jpg" loading="lazy" class="lazy"></p> <h2 id="linux上安装es"><a href="#linux上安装es" class="header-anchor">#</a> Linux上安装ES</h2> <p>请先确保 Linux 里已经安装了 jdk 1.8 以上版本。</p> <p>输入以下命令查看java版本信息，如显示以下信息，则需要安装java环境。</p> <p><img alt="es_006" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_006.jpg" loading="lazy" class="lazy"></p> <h3 id="linux上安装java"><a href="#linux上安装java" class="header-anchor">#</a> Linux上安装java</h3> <p>1、下载java安装包</p> <p><a href="https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html" target="_blank" rel="noopener noreferrer">java8下载地址<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p>2、上传安装java环境</p> <ul><li>创建jdk文件夹、并解压jdk包</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token comment"># 进入安装目录、创建文件夹</span>
<span class="token builtin class-name">cd</span> /usr/local
<span class="token function">mkdir</span> java
<span class="token builtin class-name">cd</span> java
<span class="token comment"># 上传文件命令：rz</span>
rz
<span class="token comment"># 解压 tar -zxvf 上传的jdk压缩包名</span>
<span class="token function">tar</span> -zxvf jdk-8u351-linux-x64.tar.gz
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p><img alt="es_007" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_007.jpg" loading="lazy" class="lazy"></p> <ul><li>配置环境变量、并生效配置</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token comment"># 打开配置文件</span>
<span class="token function">vim</span> /etc/profile
<span class="token comment"># 在文件末尾追加【jdk文件名：是当前解压文件夹名，如我这里的jdk1.8.0_351】</span>
<span class="token assign-left variable">JAVA_HOME</span><span class="token operator">=</span>/usr/local/java/jdk文件名
<span class="token assign-left variable">CLASSPATH</span><span class="token operator">=</span>%JAVA_HOME%/lib:%JAVA_HOME%/jre/lib
<span class="token assign-left variable"><span class="token environment constant">PATH</span></span><span class="token operator">=</span><span class="token environment constant">$PATH</span><span class="token builtin class-name">:</span><span class="token variable">$JAVA_HOME</span>/bin:<span class="token variable">$JAVA_HOME</span>/jre/bin
<span class="token builtin class-name">export</span> <span class="token environment constant">PATH</span> CLASSPATH JAVA_HOME
<span class="token comment"># esc退出编辑模式，按shift+:输入wq保存并退出</span>
<span class="token comment"># 查看配置文件</span>
<span class="token function">cat</span> /etc/profile
<span class="token comment"># 生效配置</span>
<span class="token builtin class-name">source</span> /etc/profile
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><ul><li>检查java是否安装成功</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code>java -version
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img alt="es_008" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_008.jpg" loading="lazy" class="lazy"></p> <h3 id="linux上安装es-2"><a href="#linux上安装es-2" class="header-anchor">#</a> Linux上安装es</h3> <p>1、下载es安装包</p> <p><a href="https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-8-1" target="_blank" rel="noopener noreferrer">es7.8下载地址<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p>2、上传安装es环境</p> <ul><li>创建jdk文件夹、并解压jdk包</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token comment"># 进入安装目录、创建文件夹</span>
<span class="token builtin class-name">cd</span> /usr/local/
<span class="token function">mkdir</span> elastic-stack
<span class="token builtin class-name">cd</span> elastic-stack
<span class="token comment"># 上传文件命令：rz</span>
rz
<span class="token comment"># 解压 tar -zxvf 上传的jdk压缩包名</span>
<span class="token function">tar</span> -zxvf elasticsearch-7.8.1-linux-x86_64.tar.gz
<span class="token comment"># 重命名</span>
<span class="token function">mv</span> elasticsearch-7.8.0 es
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p><img alt="es_009" data-src="https://cdn.staticaly.com/gh/LiuMWork/image-hosting@master/es_md/es_009.jpg" loading="lazy" class="lazy"></p> <ul><li><p>创建es用户、修改es配置文件</p></li> <li><p>修改elasticsearch.yml</p></li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">vim</span> /usr/local/elastic-stack/es/config/elasticsearch.yml
<span class="token comment"># 修改内容如下</span>
<span class="token comment"># ----------------------------------- Paths ------------------------------------</span>
<span class="token comment">#</span>
<span class="token comment"># Path to directory where to store the data (separate multiple locations by comma):</span>
<span class="token comment">#</span>
path.data: /data/es
<span class="token comment">#</span>
<span class="token comment"># Path to log files:</span>
<span class="token comment">#</span>
path.logs: /var/log/es
<span class="token comment"># 文件末尾中增加下面内容</span>
<span class="token comment"># 集群名</span>
cluster.name: elasticsearch
<span class="token comment"># 节点名</span>
node.name: node-1
<span class="token comment"># 允许外界访问的 ip</span>
network.host: <span class="token number">0.0</span>.0.0
<span class="token comment"># http 访问端口</span>
http.port: <span class="token number">9200</span>
<span class="token comment"># 集群节点的 master</span>
cluster.initial_master_nodes: <span class="token punctuation">[</span><span class="token string">&quot;node-1&quot;</span><span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br></div></div><ol><li>修改系统中允许应用最多创建多少文件等的限制权限。Linux 默认来说，一般限制应用最多创建的文件是 65535 个。但是 ES 至少需要 65536 的文件创建权限。</li> <li>修改系统中允许用户启动的进程开启多少个线程。默认的 Linux 限制 root 用户开启的进程可以开启任意数量的线程，其他用户开启的进程可以开启 1024个线程。必须修改限制数为 4096+。因为ES至少需要 4096 的线程池预备。ES在 5.x 版本之后，强制要求在 Linux 中不能使用 root 用户启动 ES 进程。所以必须使用其他用户启动 ES 进程才可以。</li> <li>Linux 低版本内核为线程分配的内存是 128K。4.x 版本的内核分配的内存更大。如果虚拟机的内存是 1G，最多只能开启 3000+ 个线程数。至少为虚拟机分配 1.5G 以上的内存。</li></ol> <blockquote><p>ES 可以对每个进程的文件数进行限制等，如果服务器内存或空间不足，可以通过修改配置文件</p></blockquote> <ul><li>修改其他配置文件</li></ul> <ol><li>修改/etc/security/limits.conf，在文件末尾中增加下面内容：</li></ol> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token comment"># 每个进程可以打开的文件数的限制</span>
es soft nofile <span class="token number">65536</span>
es hard nofile <span class="token number">65536</span>
<span class="token comment"># 操作系统级别对每个用户创建的进程数的限制</span>
* hard nproc <span class="token number">4096</span>
<span class="token comment"># 注：* 带表 Linux 所有用户名称</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><ol start="2"><li>修改 /etc/sysctl.conf，在文件末尾中增加下面内容</li></ol> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token comment"># 一个进程可以拥有的 VMA (虚拟内存区域)的数量,默认值为 65536</span>
vm.max_map_count<span class="token operator">=</span><span class="token number">655360</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ol start="3"><li>配置文件后，记得重新加载</li></ol> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code>sysctl -p
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>新增 elasticSearch 用户并配置权限</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">useradd</span> es
<span class="token function">passwd</span> es
<span class="token comment"># 设置的密码</span>
<span class="token comment"># 配置权限</span>
<span class="token comment"># ElasticSearch 安装目录</span>
<span class="token function">chown</span> -R es /usr/local/elastic-stack/es
<span class="token comment"># 日志文件权限</span>
<span class="token function">chown</span> -R es 日志文件安装目录
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><ul><li>启动服务</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token comment"># 切换用户</span>
<span class="token function">su</span> es
<span class="token comment"># 先进入安装目录、启动服务</span>
<span class="token builtin class-name">cd</span> /usr/local/elastic-stack/es
./bin/elasticsearch -d
<span class="token comment"># 测试访问</span>
<span class="token function">curl</span> <span class="token number">127.0</span>.0.1:9200
<span class="token punctuation">{</span>
  <span class="token string">&quot;name&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;node-1&quot;</span>,
  <span class="token string">&quot;cluster_name&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;elasticsearch&quot;</span>,
  <span class="token string">&quot;cluster_uuid&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;US9tbegDT_SfcewzyQCD3w&quot;</span>,
  <span class="token string">&quot;version&quot;</span> <span class="token builtin class-name">:</span> <span class="token punctuation">{</span>
    <span class="token string">&quot;number&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;7.8.1&quot;</span>,
    <span class="token string">&quot;build_flavor&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;default&quot;</span>,
    <span class="token string">&quot;build_type&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;tar&quot;</span>,
    <span class="token string">&quot;build_hash&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;b5ca9c58fb664ca8bf9e4057fc229b3396bf3a89&quot;</span>,
    <span class="token string">&quot;build_date&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;2020-07-21T16:40:44.668009Z&quot;</span>,
    <span class="token string">&quot;build_snapshot&quot;</span> <span class="token builtin class-name">:</span> false,
    <span class="token string">&quot;lucene_version&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;8.5.1&quot;</span>,
    <span class="token string">&quot;minimum_wire_compatibility_version&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;6.8.0&quot;</span>,
    <span class="token string">&quot;minimum_index_compatibility_version&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;6.0.0-beta1&quot;</span>
  <span class="token punctuation">}</span>,
  <span class="token string">&quot;tagline&quot;</span> <span class="token builtin class-name">:</span> <span class="token string">&quot;You Know, for Search&quot;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>3、es服务自启动设置</p> <ul><li>查看es进程、并关闭</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token comment"># 查看es进程</span>
<span class="token function">ps</span> -ef <span class="token operator">|</span> <span class="token function">grep</span> elastic
<span class="token comment"># 关闭进程</span>
<span class="token function">kill</span> -9 进程号
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><ul><li>创建elasticsearch的系统启动服务文件，进入到 cd /etc/init.d 目录</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token comment">#进入到目录,创建elasticsearch系统启动服务文件</span>
<span class="token builtin class-name">cd</span> /etc/init.d    　　
<span class="token function">vi</span> elasticsearch
<span class="token comment">#文件内容如下</span>
<span class="token comment">#!/bin/bash</span>
<span class="token comment">#chkconfig: 345 63 37</span>
<span class="token comment">#description: elasticsearch</span>
<span class="token comment">#processname: elasticsearch-7.10.2</span>
<span class="token comment"># 这个目录是你Es所在文件夹的目录</span>
<span class="token builtin class-name">export</span> <span class="token assign-left variable">ES_HOME</span><span class="token operator">=</span>/usr/local/elasticsearch-7.10.2
<span class="token keyword">case</span> <span class="token variable">$1</span> <span class="token keyword">in</span>
start<span class="token punctuation">)</span>
    <span class="token function">su</span> es<span class="token operator">&lt;&lt;</span><span class="token operator">!</span>
    <span class="token builtin class-name">cd</span> <span class="token variable">$ES_HOME</span>
    ./bin/elasticsearch -d -p pid
    <span class="token builtin class-name">exit</span>
<span class="token operator">!</span>
    <span class="token builtin class-name">echo</span> <span class="token string">&quot;elasticsearch is started&quot;</span>
    <span class="token punctuation">;</span><span class="token punctuation">;</span>
stop<span class="token punctuation">)</span>
    <span class="token assign-left variable">pid</span><span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token function">cat</span> $ES_HOME/pid<span class="token variable">`</span></span>
    <span class="token function">kill</span> -9 <span class="token variable">$pid</span>
    <span class="token builtin class-name">echo</span> <span class="token string">&quot;elasticsearch is stopped&quot;</span>
    <span class="token punctuation">;</span><span class="token punctuation">;</span>
restart<span class="token punctuation">)</span>
    <span class="token assign-left variable">pid</span><span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token function">cat</span> $ES_HOME/pid<span class="token variable">`</span></span>
    <span class="token function">kill</span> -9 <span class="token variable">$pid</span>
    <span class="token builtin class-name">echo</span> <span class="token string">&quot;elasticsearch is stopped&quot;</span>
    <span class="token function">sleep</span> <span class="token number">1</span>
    <span class="token function">su</span> es<span class="token operator">&lt;&lt;</span><span class="token operator">!</span>
    <span class="token builtin class-name">cd</span> <span class="token variable">$ES_HOME</span>
    ./bin/elasticsearch -d -p pid
    <span class="token builtin class-name">exit</span>
<span class="token operator">!</span>
    <span class="token builtin class-name">echo</span> <span class="token string">&quot;elasticsearch is started&quot;</span>
    <span class="token punctuation">;</span><span class="token punctuation">;</span>
*<span class="token punctuation">)</span>
    <span class="token builtin class-name">echo</span> <span class="token string">&quot;start|stop|restart&quot;</span>
    <span class="token punctuation">;</span><span class="token punctuation">;</span>
<span class="token keyword">esac</span>
<span class="token builtin class-name">exit</span> <span class="token number">0</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br></div></div><ul><li>修改文件权限</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">chmod</span> <span class="token number">777</span> elasticsearch
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>添加和删除服务并设置启动方式</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token comment"># 添加系统服务</span>
<span class="token function">chkconfig</span> --add elasticsearch
<span class="token comment"># 删除系统服务</span>
<span class="token function">chkconfig</span> --del elasticsearch
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><ul><li>关闭和启动服务</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token comment"># 启动服务</span>
<span class="token function">service</span> elasticsearch start
<span class="token comment"># 停止服务</span>
<span class="token function">service</span> elasticsearch stop
<span class="token comment"># 重启服务</span>
<span class="token function">service</span> elasticsearch restart
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><ul><li>查看当前的开机启动服务命令</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">chkconfig</span> --list
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>检验服务是否运行正常</li></ul> <div class="language-sh line-numbers-mode"><pre class="language-sh"><code><span class="token function">curl</span>  http://127.0.0.1:9200
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></div></div> <!----> <div class="page-edit"><!----> <div class="tags"><a href="/lm_blog_vdoing/tags/?tag=ElasticSearch" title="标签">#ElasticSearch</a></div> <!----></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/lm_blog_vdoing/pages/7b46ed/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">ElasticeSarch的概述</div></a> <a href="/lm_blog_vdoing/pages/bc6018/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">ES入门 - 基本使用：索引和文档</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/lm_blog_vdoing/pages/7b46ed/" class="prev">ElasticeSarch的概述</a></span> <span class="next"><a href="/lm_blog_vdoing/pages/bc6018/">ES入门 - 基本使用：索引和文档</a>→
      </span></p></div></div></div> <div class="article-list"><div class="article-title"><a href="/lm_blog_vdoing/archives/" class="iconfont icon-bi">最近更新</a></div> <div class="article-wrapper"><dl><dd>01</dd> <dt><a href="/lm_blog_vdoing/pages/6d9622/"><div>
            ES进阶 - 优化配置
            <!----></div></a> <span class="date">02-20</span></dt></dl><dl><dd>02</dd> <dt><a href="/lm_blog_vdoing/pages/7e4dff/"><div>
            ES进阶 - 分片操作原理
            <!----></div></a> <span class="date">02-20</span></dt></dl><dl><dd>03</dd> <dt><a href="/lm_blog_vdoing/pages/b82771/"><div>
            ES进阶 - 并发问题
            <!----></div></a> <span class="date">02-20</span></dt></dl> <dl><dd></dd> <dt><a href="/lm_blog_vdoing/archives/" class="more">更多文章&gt;</a></dt></dl></div></div></main></div> <div class="footer"><div class="icons"><a href="mailto:1512375133@qq.com" title="发邮件" target="_blank" class="iconfont icon-youjian"></a><a href="https://gitee.com/lmgghub/" title="gitee" target="_blank" class="iconfont icon-gitee"></a><a href="https://juejin.cn/user/2295436010326072" title="掘金" target="_blank" class="iconfont icon-juejin"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2023-2023
    <span>lm </span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"><div></div><div></div><div></div><div id="tcomment"></div><!----></div></div>
    <script src="/lm_blog_vdoing/assets/js/app.fa0e5fdd.js" defer></script><script src="/lm_blog_vdoing/assets/js/2.d9c93b35.js" defer></script><script src="/lm_blog_vdoing/assets/js/25.04906008.js" defer></script><script src="/lm_blog_vdoing/assets/js/5.e0bc0396.js" defer></script><script src="/lm_blog_vdoing/assets/js/13.ee87d1ca.js" defer></script><script src="/lm_blog_vdoing/assets/js/14.9d4d9cf6.js" defer></script><script src="/lm_blog_vdoing/assets/js/9.fc3a629f.js" defer></script><script src="/lm_blog_vdoing/assets/js/10.4c34cde9.js" defer></script>
  </body>
</html>
